package com.originalpoint.origin_server.pojo;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 *订单实体类
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Schema(name = "Orders" ,description = "订单信息表")
public class Orders {
    @TableId(type = IdType.AUTO)
    @Schema(name = "orderID" ,description = "订单ID")
    private Integer orderId;

    @Schema(name = "o_userId" ,description = "客户ID")
    private Integer o_userId;

    @Schema(name = "o_merId" ,description = "商家ID")
    private Integer o_merId;

    @Schema(name = "o_addressId" ,description = "地址ID")
    private Integer o_addressId;

//    虽然数据库中time为datetime数据类型，但是要手动存储时需要传递字符串，格式为YYYY-MM-DD HH:MM:SS
    @Schema(name = "time" ,description = "生成订单的时间")
    private String time;

    @Schema(name = "totalPrice" ,description = "总价格")
    private Double totalPrice;

//    由于数据库这个字段的是枚举类型，所以为String类型
    @Schema(name = "status" ,description = "订单状态")
    private String status;

    @Schema(name = "username" ,description = "客户ID")
    private String username;

    @Schema(name = "region" ,description = "订单ID")
    private String region;

    @Schema(name = "street" ,description = "区")
    private String street;

    @Schema(name = "detailAddress" ,description = "详细地址")
    private String detailAddress;


//    mapper结果集封装，需要merchat和address实体
@Schema(name = "merchat" ,description = "封装着商家的信息")
    private Merchat merchat;

    @Schema(name = "address" ,description = "封装着地址的信息")
    private Address address;

//    用户功能-订单插入，特殊字段有参构造
    public Orders(Integer o_userId, Integer o_merId, Integer o_addressId, Double totalPrice) {
        this.o_userId = o_userId;
        this.o_merId = o_merId;
        this.o_addressId = o_addressId;
        this.totalPrice = totalPrice;
    }
}
